home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Libris Britannia 4
/
science library(b).zip
/
science library(b)
/
PROGRAMM
/
CC_C
/
0574.ZIP
/
GETW.ASM
< prev
next >
Wrap
Assembly Source File
|
1986-08-28
|
933b
|
68 lines
include compiler.inc
ttl GETW, 1.04, 08-28-86, clr
;single word stream input
dseg
extrn _ftb:byte
cseg
xtfs <read,$strhand>
procdef getw, <<strm, ptr>>
locs <<bufp,ptr>>
pushreg
callit $strhand <<strm,ptr>>
inc ax
jz reteof
dec ax ;ax holds handle
ldptr si,strm ;re-load stream pointer
test bl,1
jz seterr ;not open for reading
test bl,18h
jnz reteof ;already set
pushds
push si
mov bx,2 ;count
callit read,<<bx,reg>,<bufp,ptr>,<ax,reg>>
push ax
ldptr si,bufp
cld
lodsw
mov di,ax
pop ax
pop si
popds
or ax,ax
jz seteof ;nothing returned - set EOF
inc ax
or ax,ax ;error!
jz seterr
jmp getval
seterr:
or byte ptr 2[si],10h ;set error flag
jmp reteof
seteof:
or byte ptr 2[si],08h ;yes, set EOF
reteof:
mov ax,-1
jmp short fini
;
getval:
mov ax,di ;and return byte
fini:
pret
pend getw
finish